Add consent token security & rate limiting for OAuth flow - #102
Merged
Conversation
Clients like Cursor could auto-approve MCP authorization by calling the /oauth/consent/approve HTTP endpoint directly, bypassing the desktop consent UI entirely. - Remove public HTTP consent endpoint; approval now requires Tauri IPC - Add cryptographic consent_token shared only via desktop app IPC - Add 2-second cooldown on Approve button to prevent instant approval - Add per-path rate limiting on OAuth endpoints - Guard E2E-only approve command behind MCPMUX_E2E_TEST env var Signed-off-by: Claude <noreply@anthropic.com> https://claude.ai/code/session_019gtFefwPpKWZH73DEyUpE2 Signed-off-by: Claude <noreply@anthropic.com>
its-mash
force-pushed
the
claude/fix-approval-deeplink-hbvgC
branch
from
February 16, 2026 08:19
1016945 to
326c0e4
Compare
The previous commit gated /oauth/consent/approve behind the MCPMUX_E2E_TEST env var but the e2e test runner was not passing it to the tauri-driver process. This caused streamable-http tests to fail because obtainAccessToken() and approveOAuthClient() both depend on test-only endpoints. https://claude.ai/code/session_019gtFefwPpKWZH73DEyUpE2 Signed-off-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR implements two critical security improvements to the OAuth consent flow:
Consent Token Security: Introduces cryptographic consent tokens that are shared exclusively via Tauri IPC (desktop app UI), preventing unauthorized consent approval via HTTP endpoints. The token must be validated on approval, ensuring only the legitimate desktop app can approve OAuth requests.
Rate Limiting: Adds per-path rate limiting middleware for OAuth endpoints to prevent abuse and consent flooding attacks. Includes configurable limits for
/oauth/authorize,/oauth/token,/oauth/register, and/oauth/clientsendpoints.HTTP Endpoint Removal: Removes the
/oauth/consent/approveHTTP endpoint from production builds. Consent approval now happens exclusively via the Tauri IPC commandapprove_oauth_consent, which can only be invoked by the desktop app's WebView—not by external scripts or bots. The endpoint is re-enabled only in E2E test mode (guarded byMCPMUX_E2E_TESTenv var).UI Safeguard: Adds a 2-second cooldown before the Approve button becomes active in the consent modal, preventing instant automated approval and giving users time to review the request.
Key Changes:
crates/mcpmux-gateway/src/server/rate_limit.rs- Rate limiting middleware with configurable rulescrates/mcpmux-gateway/src/server/handlers.rs- Generate and validate consent tokens; add token toPendingAuthorizationcrates/mcpmux-gateway/src/server/mod.rs- Remove HTTP consent endpoint from production; add rate limiting layer; conditionally enable endpoint in E2E test modeapps/desktop/src-tauri/src/commands/oauth.rs- Validate consent tokens inapprove_oauth_consent; guardapprove_oauth_clientwith E2E test flagapps/desktop/src/components/OAuthConsentModal.tsx- Include consent token in approval requests; add 2-second cooldown before Approve button is activetests/e2e/helpers/mcp-client.ts- Document that/oauth/consent/approveis E2E-test-onlyHow was it tested?
MCPMUX_E2E_TEST=1get_pending_consentandapprove_oauth_consentpathsChecklist
https://claude.ai/code/session_019gtFefwPpKWZH73DEyUpE2